package imagekeeper.data;

import java.sql.Connection;
import java.sql.Types;
import java.sql.SQLException;
import imagekeeper.dmi.Image;
import imagekeeper.data.mapping.ImageMapper;


class SqlStatementUpdateImage extends SqlStatement {
    private final static String ParamImageId = "pId";
    private final static String ParamImageTitle = "pTitle";
    private final static String ParamImageDescription = "pDescription";
    private final static String ParamImagePrivacy = "pPrivacy";
    private final static String ParamImageViews = "pViews";
    private final static String ParamImageTotalUserMark = "pUserTotalMark";
    private final static String ParamImageUserMarkCounter = "pUserMarkCounter";
    
    public SqlStatementUpdateImage(Connection con, Image img) throws SQLException {
        statement = con.prepareCall("{call " + ImageMapper.SpUpdateImage + "(?,?,?,?,?,?,?)}");
        statement.setInt(ParamImageId, img.getId());
        setParameter(ParamImageTitle, img.getTitle(), Types.VARCHAR);
        setParameter(ParamImageDescription, img.getDescription(), Types.VARCHAR);
        statement.setBoolean(ParamImagePrivacy, img.getPrivacy());
        statement.setInt(ParamImageViews, img.getViews());
        statement.setInt(ParamImageTotalUserMark, img.getTotalUserMark());
        statement.setInt(ParamImageUserMarkCounter, img.getUserMarkCounter());
    }
}
